import qs from 'qs'
import axios from 'axios'
axios.defaults.baseURL = "http://127.0.0.1:5000/"

const myaxios = function (url, method, data = {}) {
    return new Promise((resolve) => {
        if (method == 'get' || method == 'delete') {
            axios({
                'method': method,
                'url': url,
                'params': qs.stringify(data)
            }).then(res => {
                resolve(res.data)
            })
        } else {
            axios({
                'method': method,
                'url': url,
                'data': qs.stringify(data)
            }).then(res => {
                resolve(res.data)
            })
        }
    })
}
export default myaxios